// import proFetch from "../../../../../public/functions/project-fetch";
import {hrAjax as ajax} from 'src/hrpub/common/utils/utils';
import updateButtonStatus from "./updateButtonStatus";


export default function getOneAgreementInfo() {
    const {editPk, agreementType, refreshFlag, json,orgVal,pageFlag} = this.state;
    const {form} = this.props;
    if(!editPk){
        // 20190709 详情页 删除后，若没有数据了则清空数据，不可跳到列表页
        if(pageFlag==='card'){
            form.EmptyAllFormValue(`${agreementType}Card`);
            updateButtonStatus.call(this, orgVal, agreementType, true);
        }
        /*this.setState({
            pageFlag: 'list', //页面状态
            isEdit: false,
        }, () => {

            if (this.state.pageFlag === 'list') {
                this.getMainTableData();
            }
        });*/
        return ;
    }
    return ajax({
        url: '/nccloud/hrcm/agreement/ReleaseQueryOneAction.do',
        body:{
            pk_agreement: editPk,
            agreementType: agreementType,
            nodecode: '60110507',
        }
    })
        .then((res) => {
            if (res.success) {
                if (res.data) {
                    let cardId;
                    if(res.data.postcontCard){
                        form.setAllFormValue({'postcontCard': res.data.postcontCard});
                    }else if(res.data.secrerycontCard){
                        form.setAllFormValue({'secrerycontCard': res.data.secrerycontCard});
                    }else if(res.data.traincontCard){
                        form.setAllFormValue({'traincontCard': res.data.traincontCard});
                    }else{
                        cardId = agreementType+"Card";
                        let data = res.data[cardId];
                        form.setAllFormValue({[cardId]: data});
                    }
                    this.props.cardPagination.setCardPaginationId ({id:editPk,status:1})
                }
            }
        });
}
